<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use common\models\business\BusinessVariety;
use common\models\business\BusinessPig;
use common\models\business\BusinessException;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\business\models\BusinessPigSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '仔猪财务明细';
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
            <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">



                <div class="business-pig-index">



                    <?php
                    echo GridView::widget([
                        'dataProvider'=>$dataProvider,
                        'filterModel'=>$searchModel,
                        'showPageSummary'=>true,
                        'pjax'=>false,
                        'striped'=>true,
                        'hover'=>true,
                        'panel'=>['type'=>'primary', 'heading'=>'仔猪财务明细'],
                        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
                        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
                        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
                        'columns'=>[
                            [
                                'attribute'=>'no',
                                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                                'width'=>'100px',
                            ],
                            [
                                'attribute'=>'batch',
                                'width'=>'100px',
                            ],

                            [
                                'label' => '养殖成本',
                                'value' => function($model){
                                    return $model->getDailyCost();
                                },
                                'format'=>['decimal', 2],
                                'pageSummary'=>true,
                                'width'=>'100px',
                            ],
                            [
                                'attribute' => 'cost',
                                'label' => '购买成本',
                                'width'=>'100px',
                                'format'=>['decimal', 2],
                                'pageSummary'=>true,
                            ],
                            [
                                'attribute' => 'back.backprice',
                                'label' => '回购价格',
                                'width'=>'100px',
                                'format'=>['decimal', 2],
                                'pageSummary'=>true,
                            ],
                            [
                                'attribute' => 'fg.fgcost',
                                'label' => '分割成本',
                                'width'=>'100px',
                                'format'=>['decimal', 2],
                                'pageSummary'=>true,
                            ],

                            [
                                'value' => function($model){
                                    return $model->getTotal();
                                },
                                'label' => '总计',
                                'width'=>'100px',
                                'format'=>['decimal', 2],
                                'pageSummary'=>true,
                            ],
                            [
                                'class' => '\kartik\grid\ActionColumn',
                                'deleteOptions' => ['label' => '<i class="glyphicon glyphicon-remove"></i>'],
                                'options' => ['width' => '100px;'],
                                'template' => '{view}',
                                'buttons' => [
                                    'view' => function ($url, $model) {
                                        return Html::a('<span class="glyphicon glyphicon-eye-open"></span>',Url::to(['/business/pig/view','id'=>$model->id]),[
                                            'title' => '详情'
                                        ]);
                                    }
                                ],
                            ],
                            /* [
                                 'class' => '\kartik\grid\CheckboxColumn'
                             ]*/
                        ],
                        'toolbar'=> [

                            '{export}',
                            '{toggleData}',
                        ],
                        'bordered'=>true,
                        'condensed'=>true,
                    ]);
                    ?>



                </div>
            </div>
        </div>
    </section>
</section>
<script>
    <?php $this->beginBlock('js_end') ?>
    <?php $this->endBlock(); ?>
    <?php $this->registerJs($this->blocks['js_end'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>



